<template>
  <div>
  <p :class="{red_str:bo}" @click="ddd">动态class</p>
    <p :style="{backgroundColor:colorStr}">动态style</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
     bo:true,
      colorStr:"red"
    };
  },
  methods: {
   ddd(){
      if (this.bo){this.bo=false}else{
        this.bo=true
      }
   }
  }
};
</script>

<style scoped>
.red_str{
  color:red;
}
</style>